package lbframework.bean.spinner;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

public class LBSpinner extends JSpinner {

    private int max = 0;

    public LBSpinner() {
        initComponents();
    }

    public int getIntValue()throws Exception {
        return Integer.valueOf(getValue().toString());

    }

    public void setIntValue(int i_value)throws Exception {
        if(i_value > max){
            this.setValue(max);
        }else{
            this.setValue(i_value);
        }
    }

    public void setMax(int i_max)throws Exception {
        max = i_max;
        this.setModel(new SpinnerNumberModel(0, 0, max, 1));
    }

    public int getMax()throws Exception {
        return max;
    }

    //@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
        setMinimumSize(new java.awt.Dimension(30, 20));
        setPreferredSize(new java.awt.Dimension(30, 20));
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
